#ifndef COBJECTIO_H
#define COBJECTIO_H
#include "rados/librados.hpp"
#include "ErrorCode.h"

namespace gitstore {

class StoreObject;

class CObjectIOBase
{
public:
    CObjectIOBase();
    virtual ~CObjectIOBase();

public:
    ErrorStatus setValue(const std::string& key, const StoreObject& value);
    ErrorStatus getValue(const std::string& key, StoreObject& value);

    virtual ErrorStatus setValue(const std::string& key, const std::string& value) = 0;
    virtual ErrorStatus getValue(const std::string& key, std::string& value) = 0;
};


class CLinuxObjectIOBase final : public CObjectIOBase {
public:
    CLinuxObjectIOBase();
    virtual ~CLinuxObjectIOBase() override;

public:
    virtual ErrorStatus setValue(const std::string& key, const std::string& value)  override;
    virtual ErrorStatus getValue(const std::string& key, std::string& value)  override;

private:
    std::string store_path = "/home/luqin2/gitstoredata/";
};

#ifdef COMPILE_CEPH
class CCephObjectIO : public CObjectIOBase {
public:
    CCephObjectIO(const std::string& cluster_name, const std::string& user_name, const std::string& config_file_path, const std::string& pool_name);
    virtual ~CCephObjectIO() override;

public:
    virtual ErrorStatus setValue(const std::string& key, const std::string& value)  override;
    virtual ErrorStatus getValue(const std::string& key, std::string& value)  override;

private:
    librados::Rados _cluster;
    librados::IoCtx _io_ctx;
};
#endif
}

#endif // COBJECTIO_H
